﻿using System;
using System.Collections.Generic;
using System.Linq;
using Common.Extension;
using Common.Model;
using Common.util;
using Dapper;

namespace Common.Dao
{
    public class StopWordDao
    {
        //获取停用词
        public static List<string> GetStopWord()
        {
            String sql = "SELECT word FROM `words_stop`";
            using (var conn = DbUtils.GetHotTopicConnection())
            {
                return conn.Query<string>(sql)?.ToList();
            }
        }
        
        //保存关键词模型
        public static void BatchSaveStopWord(List<string> models)
        {
            var list = models.Select(m=>new
            {
                word = m
            }).ToList();
            
            String sql =
                @"INSERT IGNORE `words_stop`(word) VALUES (@word)";
            using (var conn = DbUtils.GetHotTopicConnection())
            {
                conn.InsertMultiple(sql, list);
            }
        }
    }
}